package cn.linjianhui.flink.sample.model;

import org.apache.commons.compress.utils.Sets;

import java.math.BigDecimal;
import java.util.Set;

public class OrderAccumulator {
    private String orderSource;
    private BigDecimal totalPayAmount;
    private Long totalPayOrder;
    private Long cancelOrderNum;
    private BigDecimal cancelPayAmount;
    private Set<String> orderIds;
    private Set<String> cancelOrderIds;

    public OrderAccumulator() {
        orderSource = "";
        totalPayOrder = 0L;
        cancelOrderNum = 0L;
        totalPayAmount = new BigDecimal(0);
        cancelPayAmount = new BigDecimal(0);
        orderIds = Sets.newHashSet();
        cancelOrderIds = Sets.newHashSet();
    }

    public void setTotalPayAmount(BigDecimal totalPayAmount) {
        this.totalPayAmount = totalPayAmount;
    }

    public void setTotalPayOrder(Long totalPayOrder) {
        this.totalPayOrder = totalPayOrder;
    }

    public void setCancelOrderNum(Long cancelOrderNum) {
        this.cancelOrderNum = cancelOrderNum;
    }

    public void setCancelPayAmount(BigDecimal cancelPayAmount) {
        this.cancelPayAmount = cancelPayAmount;
    }

    public void setOrderIds(Set<String> orderIds) {
        this.orderIds = orderIds;
    }

    public void setCancelOrderIds(Set<String> cancelOrderIds) {
        this.cancelOrderIds = cancelOrderIds;
    }

    public String getOrderSource() {
        return orderSource;
    }

    public void setOrderSource(String orderSource) {
        this.orderSource = orderSource;
    }

    public BigDecimal getTotalPayAmount() {
        return totalPayAmount;
    }

    public void addPayAmount(BigDecimal amount) {
        this.totalPayAmount = this.totalPayAmount.add(amount);
    }

    public Long getTotalPayOrder() {
        return totalPayOrder;
    }

    public void addPayOrder(Long order) {
        this.totalPayOrder += order;
    }

    public boolean containsOrder(String orderId) {
        return this.orderIds.contains(orderId);
    }

    public Set<String> getOrderIds() {
        return orderIds;
    }

    public boolean addOrderId(String orderId) {
        return this.orderIds.add(orderId);
    }

    public boolean addOrderIds(Set<String> orderIds) {
        return this.orderIds.addAll(orderIds);
    }

    public Long getCancelOrderNum() {
        return cancelOrderNum;
    }

    public BigDecimal getCancelPayAmount() {
        return cancelPayAmount;
    }

    public void addCancelOrderNum(Long num) {
        this.cancelOrderNum += num;
    }

    public void addCancelPayAmount(BigDecimal amount) {
        this.cancelPayAmount = this.cancelPayAmount.add(amount);
    }

    public Set<String> getCancelOrderIds() {
        return cancelOrderIds;
    }

    public boolean containsCancelOrder(String orderId) {
        return this.cancelOrderIds.contains(orderId);
    }

    public boolean addCancelOrderId(String orderId) {
        return this.cancelOrderIds.add(orderId);
    }

    public boolean addCancelOrderIds(Set<String> orderIds) {
        return this.cancelOrderIds.addAll(orderIds);
    }
}
